<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>debounce</title>
</head>

<body>

    <script>
        // 防抖动
        function debounce(fn,delay,imt ) {
           let tim =null ;
           return function(){
              if (tim) clearTimeout(fn);//1.不触发就清除计时器
              //2.计时器
              if(imt){
                tim=setTimeout(function(){
                  fn;
              },delay);
              }
           }

        }

        // 立即执行的判断？？
    </script>
</body>

</html>